<!DOCTYPE html>
<html lang="en">

<head>
  <!-- head and css -->
  {% include 't_head.html' %}
</head>

<body>
  <div class="d-flex" id="wrapper">
    <!-- Sidebar -->
    {% include 't_sidebar.html' %}

    <!-- Page Content -->
    <div id="page-content-wrapper">

      <!-- Navbar -->
      {% include 't_navbar.html' %}

      <div class="container-fluid">

        <br>
        <h3>Design and eval FRIDA scripts on the fly 🚀</h3>
        <div class="border-top my-3"></div>
        <!-- Textarea for injecting the custom script -->
        <div class="row">

          <div class="col-sm-9">
            <form action="/load_frida_script" method="post">
              <textarea id=hooktable name=frida_custom_script class="form-control">{{ custom_script_loaded }}</textarea>
              <br>
              <center><input type=submit value="Run Custom Frida Script" class="btn btn-success"></center>
              <br>
            </form>
          </div>

          <div class="col-sm-3 
          form-group 
          list-group-item 
          list-group-item-action 
          bg-light 
          rounded">
            <h5>Load your custom FRIDA Scripts</h5>
            <div class="border-top my-3"></div>
            <div class="list-group">
              {% for cs in custom_scripts %}
              <a href="load_frida_script?cs={{ cs }}" class="list-group-item list-group-item-action">
                [{{ loop.index }}] - {{ cs }}
              </a>
              {% endfor %}
            </div>
            <div class="border-top my-3"></div>
            <small class="form-text text-muted">
              Scripts are automatically loaded from the <font color=red>custom_scripts</font> folder. Make sure to add your favorite <font color=red>.js</font> scripts! 😉
            </small>
          </div>

        </div><!-- /#row -->

      </div>
      <!-- /#container-fluid -->

    </div>
    <!-- /#page-content-wrapper -->

  </div>
  <!-- /#wrapper -->

  <!-- Javascript loading -->
  {% include 't_js_script.html' %}

  {% block scripts %}
  <script>
    var editor = CodeMirror.fromTextArea(hooktable, {
        lineNumbers: true,
        mode: 'javascript',
        theme: 'dracula'
    });
    editor.setSize("100%",550);
  </script> 

  <!-- Set current Page as active in the NavBar -->
  <script>
    $(document).ready(function () {
      $(".nav li").removeClass("active");
      $('#custom_frida_script').addClass('active');
    });
    </script>
  <!-- Set current Page as active in the NavBar -->

  {% endblock %}

</body>

</html>